/**
 * @Title:  AuthMechanismActivity.java
 * @Copyright:  XXX Co., Ltd. Copyright YYYY-YYYY,  All rights reserved 
 * @Description:  TODO<请描述此文件是做什么的> 
 * @author:  MeiYi
 * @data:  2016-1-5 上午11:24:06 
 * @version:  V1.0
 */

package artid.com.arttogo.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
import com.android.volley.VolleyError;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import artid.com.arttogo.R;
import artid.com.arttogo.adapter.ArtCollectorsAdapter;
import artid.com.arttogo.adapter.ArtNewsAdapter;
import artid.com.arttogo.app.ArtToGoApp;
import artid.com.arttogo.bean.ArtNewsCate;
import artid.com.arttogo.bean.ChannelItem;
import artid.com.arttogo.bean.NewsContent;
import artid.com.arttogo.bean.NewsList;
import artid.com.arttogo.db.Cache;
import artid.com.arttogo.db.ChannelDao;
import artid.com.arttogo.network.AppUtil;
import artid.com.arttogo.network.VolleyBasic;
import artid.com.arttogo.network.VolleyCallback;
import artid.com.arttogo.network.VolleyData;
import artid.com.arttogo.network.VolleyMap;
import artid.com.arttogo.utils.ChannelManage;
import artid.com.arttogo.utils.MySharedPreferences;
import artid.com.arttogo.view.MyListView;
import artid.com.arttogo.view.pulllist.PullToRefreshLayout;

/**
 * 艺术资讯
 *
 * @data: 2016-1-5 上午11:24:06
 * @version: V1.0
 */
public class ArtNewsActivity extends BaseActivity implements OnClickListener {
	public static Boolean isBackFromChannel = false;
	public static int ChannelPosition = -1;
	private Context mContext;
	private GridView mGridView;
	private ArtCollectorsAdapter adapter;
	// private ImageView back;
	ImageView mimgMirrorCenter, mimgMirrorLeft;

	LinearLayout linearSearch;
	private int anmiSpeed = 400;
	View viewHide;
	// Boolean isRefsh = false;
	int pageIndex = 1, pagesize = 20;
	// View mainView;
	// View titleSearch;
	String strType = "1";
	/** 屏幕宽度 */
	private int mScreenWidth;
	/** 导航条目宽度 */
	private int item_width;
	// List<ArtNewsCate.channel> typeList;
	int endPosition = 0, beginPosition, currentFragmentIndex;
	ImageView mImageView;
	/** 导航栏 */
	private HorizontalScrollView mHorizontalScrollView;
	private LinearLayout mLinearLayout;
	String searchWord = "";
	View slideMain, viewPic;
	private MyListView mListView;
	private PullToRefreshLayout mPullLayout;
	private boolean isRefreshed = false;// 是否刷新
	private int page = 1;
	private ArrayList<NewsList> list;
	private ArrayList<NewsList> more_list;
	private ArtNewsAdapter adapter_ListView;
	private PopupWindow window;
	// 请求类别
	// private String ac_id="1";
	// 请求排序
	private String id = "1";
	TextView mViewNotif;
	private ImageView plus;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_artnews);
		mContext = ArtNewsActivity.this;
		mLinearLayout = (LinearLayout) findViewById(R.id.hsv_content);
		mHorizontalScrollView = (HorizontalScrollView) findViewById(R.id.hsv_view);
		mViewNotif = (TextView) findViewById(R.id.news_notif);
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		mScreenWidth = dm.widthPixels;
		item_width = (int) ((mScreenWidth / 5.0));
		mImageView = (ImageView) findViewById(R.id.img1);
		mImageView.getLayoutParams().width = item_width;
		// titleSearch = (View) findViewById(R.id.collecter_serach);
		slideMain = (View) findViewById(R.id.artist_slideView);
		// mainView = (View) findViewById(R.id.art_collect_view);
		mGridView = (GridView) findViewById(R.id.gridview);
		viewHide = (View) findViewById(R.id.view_hide_text);
		plus = (ImageView) findViewById(R.id.iv_plus);
		viewHide.setVisibility(View.GONE);
		viewHide.setOnClickListener(this);
		plus.setOnClickListener(this);
		// titleSearch.setOnClickListener(this);
		mBack = (ImageView) findViewById(R.id.back_btn);
		mTittle = (TextView) findViewById(R.id.tittle_text);
		mTittle.setText("资讯");
		mBack.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		// 得到数据类对象
		manage = ChannelManage.getManage(ArtToGoApp.getInstance()
				.getSQLHelper());
		CD = new ChannelDao(ArtNewsActivity.this);
		list = new ArrayList<NewsList>();
		more_list = new ArrayList<NewsList>();
		mListView = (MyListView) findViewById(R.id.ListViewAndHorizonListview_ListView);

		mPullLayout = (PullToRefreshLayout) findViewById(R.id.refresh_layout);
		mPullLayout.setVisibility(View.INVISIBLE);

		mPullLayout.setOnRefreshListener(new PullToRefreshLayout.OnRefreshListener() {

			@Override
			public void onRefresh(PullToRefreshLayout pullToRefreshLayout) {
				// TODO Auto-generated method stub
				// 下拉刷新
				page = 1;
				isRefreshed = true;

				getArtistListData();
			}

			@Override
			public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) {
				// TODO Auto-generated method stub
				// pullToRefreshLayout.setBottomDismiss();
				// 上拉加载
				page++;
				getArtistListData();
			}
		});

		// hint = (LinearLayout) findViewById(R.id.ll_hint);
		// ImageView imgblank = (ImageView) hint.findViewById(R.id.img_blank);
		// imgblank.setImageResource(R.drawable.blank_artist);
		// ((TextView) findViewById(R.id.text_blank)).setText("目前没有相关艺术资讯");
		// hint.setVisibility(View.GONE);
		if (!TextUtils.isEmpty(AppUtil.getUser().getToken())) {
			requestCategoryList();
		} else {
			String json = MySharedPreferences.getMySharedPreferences(
					ArtNewsActivity.this).getValue("mychannel", "");
			int userNum = 0;
			int otherNum = 0;
			JSONObject channel;
			try {
				channel = new JSONObject(json);
				JSONObject mychannelObj = channel.optJSONObject("data")
						.optJSONObject("mychannel");
				JSONArray allchannelArr = channel.optJSONObject("data")
						.optJSONArray("allchannel");
				for (int i = 0; i < allchannelArr.length(); i++) {
					String id = allchannelArr.optJSONObject(i).optString("id");
					String title = allchannelArr.optJSONObject(i).optString(
							"title");
					if (i < allchannelArr.length() / 2) {
						userNum++;
						ChannelManage.defaultUserChannels.add(new ChannelItem(
								Integer.valueOf(id), title, userNum, 1));
					} else {
						otherNum++;
						ChannelManage.defaultOtherChannels.add(new ChannelItem(
								Integer.valueOf(id), title, otherNum, 0));
					}
				}
				userChannelList = ((ArrayList<ChannelItem>) manage
						.getUserChannel());
				initNav();
				getArtistListData();
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

	private void initNav() {
		// String[] arrTag = {"简介","动态","在售","资讯"};
		mLinearLayout.removeAllViews();

		for (int i = 0; i < userChannelList.size(); i++) {
			RelativeLayout layout = new RelativeLayout(this);
			TextView view = new TextView(this);
			view.setText(userChannelList.get(i).getName());
			view.setGravity(Gravity.CENTER_VERTICAL);
			RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
					LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
			params.addRule(RelativeLayout.CENTER_IN_PARENT);
			layout.addView(view, params);
			mLinearLayout.addView(layout, item_width,
					Cache.dip2px(mContext, 40));
			layout.setOnClickListener(onClickType());
			layout.setTag(i);

		}
		strType = userChannelList.get(0).getId() + "";
		mTittle.setText(userChannelList.get(0).getName());
	}

	/**
	 * 获取艺术家信息和作品信息。 页数 page 条数 pagesize 艺术家类别 ac_id 口令 token 排序规则 orderid
	 * 默认的排序规则是降序 默认排序：1； 按人气从高到底：2 按加入顺序倒序：3 按作品数从多到少：4 按点赞数从高到底：5 按姓氏从A-Z：6
	 */
	private static List<ImageView> dotViewList;
	ArrayList<String> imgFocusList, urlFocusList, idList,
			artistRankingTitleList;
	private ChannelDao CD;
	Boolean isFirstLoad = true;

	private void getArtistListData() {

		String time = CD.getTimeStamp(Integer.valueOf(strType));
		VolleyBasic.getInstance(this).post(
				Cache.newsListnew,
				VolleyMap.getInstance().newsList(time, String.valueOf(page),
						strType), NewsList.class, new VolleyCallback() {

					@Override
					public void onSuccess(VolleyData vd) {
						// TODO Auto-generated method stub
						CD.updateTimeStamp(strType, getTime());
						mPullLayout.loadmoreFinish(mPullLayout.SUCCEED);
						mPullLayout.setVisibility(View.VISIBLE);
						NewsContent mBean = new NewsContent();
						list = (ArrayList<NewsList>) vd.getList();
						int num = 0;// 当前有多少条新数据
						try {
							num = new JSONObject(vd.getJson()).optInt("num");
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						// list = mBean.getArtistList();
						if (isRefreshed == true) {
							more_list.clear();
							isRefreshed = false;
							mViewNotif.setVisibility(View.VISIBLE);
							if (num > 0) {
								mViewNotif.setText("为你推荐了" + num + "篇新内容");
							} else {
								mViewNotif.setText("暂无新荐内容，休息一会儿");
							}
							new Handler().postDelayed(new Runnable() {

								public void run() {
									// execute the task
									mViewNotif.setVisibility(View.GONE);
								}
							}, 2000);
						}
						if (!list.isEmpty()) {
							more_list.addAll(list);
						}
						/*
						 * //这里是显示有数据和无数据的布局 if(more_list!=null &&
						 * more_list.size()!=0){
						 * noDataLL.setVisibility(View.GONE); }else{
						 * noDataLL.setVisibility(View.VISIBLE); return; }
						 */
						if (adapter_ListView == null) {
							adapter_ListView = new ArtNewsAdapter(mContext,
									more_list);
							mListView.setAdapter(adapter_ListView);
							setItemClick(more_list);
						}
						adapter_ListView.notifyDataSetChanged();
						Log.d("log", more_list.toString());

						// 轮播加载

						// mainView.setVisibility(View.VISIBLE);
						viewHide.setVisibility(View.GONE);

					}

					@Override
					public void onError(VolleyError volleyError) {
						// TODO Auto-generated method stub
						mPullLayout.loadmoreFinish(mPullLayout.FAIL);
						/*
						 * 这里是显示有数据和无数据的布局 if(more_list!=null &&
						 * more_list.size()!=0){
						 * noDataLL.setVisibility(View.GONE); }else{
						 * noDataLL.setVisibility(View.VISIBLE); return; }
						 */
					}
				});
	}

	View.OnClickListener onClickType() {
		View.OnClickListener listener = new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				int position = (Integer) arg0.getTag();
				setType(position);
			}
		};
		return listener;

	}

	void setType(int position) {
		strType = userChannelList.get(position).getId() + "";

		Animation animation = new TranslateAnimation(endPosition, position
				* item_width, 0, 0);
		beginPosition = position * item_width;

		currentFragmentIndex = position;
		if (animation != null) {
			animation.setFillAfter(true);
			animation.setDuration(0);
			mImageView.startAnimation(animation);
			mHorizontalScrollView.smoothScrollTo((currentFragmentIndex - 1)
					* item_width, 0);
		}

		page = 1;
		// isRefreshed = true;
		mTittle.setText(userChannelList.get(position).getName());
		adapter_ListView = null;
		more_list.clear();
		getArtistListData();
	}

	/** 用户栏目列表 */
	public static ArrayList<ChannelItem> userChannelList = new ArrayList<ChannelItem>();

	/**
	 * 请求类别
	 */
	private void requestCategoryList() {
		VolleyBasic.getInstance(ArtNewsActivity.this).post(Cache.mychannel,
				VolleyMap.getInstance().mychannel(), ArtNewsCate.class,
				new VolleyCallback() {

					@Override
					public void onSuccess(VolleyData vd) {
						// TODO Auto-generated method stub
						System.out.println(vd.getJson());
						// Toast.makeText(mContext, vd.getJson(), 2).show();
						@SuppressWarnings("unchecked")
						final ArtNewsCate item = (ArtNewsCate) vd.getData();
						// typeList = item.getListitemAll();
						initChannelList(vd.getJson());
						userChannelList = ((ArrayList<ChannelItem>) manage
								.getUserChannel());
						initNav();
						// initNav(typeList);
						getArtistListData();
					}

					@Override
					public void onError(VolleyError volleyError) {
						// TODO Auto-generated method stub

					}
				});
	}

	/**
	 * 请求类别
	 */
	private void requestEditchannel(String ids) {
		VolleyBasic.getInstance(ArtNewsActivity.this).post(Cache.editchannel,
				VolleyMap.getInstance().editchannel(ids), ArtNewsCate.class,
				new VolleyCallback() {

					@Override
					public void onSuccess(VolleyData vd) {
						// TODO Auto-generated method stub
						System.out.println(vd.getJson());
					}

					@Override
					public void onError(VolleyError volleyError) {
						// TODO Auto-generated method stub

					}
				});
	}

	// void reqData(final String keywork) {
	//
	// VolleyBasic.getInstance(ArtCollectorsNewActivity.this).post(
	// Cache.artistList,
	// VolleyMap.getInstance().artistList(strType,String.valueOf(pageIndex),
	// String.valueOf(pagesize), keywork,
	// AppUtil.getUser().getToken()), ArtistList.class,
	// new VolleyCallback() {
	//
	// @Override
	// public void onSuccess(VolleyData vd) {
	// // TODO Auto-generated method stub
	// mPullLayout.setVisibility(View.VISIBLE);
	// mPullLayout.loadmoreFinish(mPullLayout.SUCCEED);
	// List<ArtistList> list = (List<ArtistList>) vd
	// .getList();
	// hint.setVisibility(View.GONE);
	//
	// if (list.isEmpty()) {
	// if (pageIndex==1) {
	// list =new ArrayList<ArtistList>();
	// adapter.setdata(list,keywork);
	// hint.setVisibility(View.VISIBLE);
	// }
	// if (adapter.listdata.isEmpty()) {
	// hint.setVisibility(View.VISIBLE);
	// }
	// return;
	// }
	// if (pageIndex!=1) {
	// adapter.addlist(list);
	// setItemClick(adapter.listdata);
	//
	// return;
	// }
	// adapter = new ArtCollectorsAdapter(mContext);
	// adapter.setdata(list, keywork);
	// mGridView.setAdapter(adapter);
	// setItemClick(list);
	// mainView.setVisibility(View.VISIBLE);
	// viewHide.setVisibility(View.GONE);
	// }
	//
	// @Override
	// public void onError(VolleyError volleyError) {
	// // TODO Auto-generated method stub
	// mPullLayout.setVisibility(View.VISIBLE);
	// mPullLayout.loadmoreFinish(mPullLayout.FAIL);
	// }
	// });
	// }

	void setItemClick(final ArrayList<NewsList> list) {
		mListView.setOnScrollListener(new MyListView.OnScrollListener() {

			@Override
			public void onScrollStateChanged(AbsListView arg0, int arg1) {
				// TODO Auto-generated method stub
				Log.d("ScrollState", arg1 + "");
				Log.d("lastvisible", mListView.getLastVisiblePosition() + "");
			}

			@Override
			public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
				// TODO Auto-generated method stub
				 Log.d("onScroll","firstVis="+arg1+"");
				 Log.d("onScroll","visibleItemCount="+arg2+"");
				 Log.d("onScroll","totalItemCount="+arg3+"");
			}
		});
		mListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
									int position, long id) {
				// TODO Auto-generated method stub
				// ViewGroup vGroup =
				// (ViewGroup)mGridView.getChildAt(position);
				// int y = (view.getTop());
				// int x = (view.getLeft());
				// Point point = new Point(x, y);
				// Intent intent = new Intent(
				// ArtCollectorsActivity.this,
				// CollecterActivity.class);
				Intent intent = new Intent(ArtNewsActivity.this,
						ArtNewsDetailActivity.class);
				intent.putExtra("id", list.get(position).getId());

				startActivity(intent);

			}
		});
	}

	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		switch (view.getId()) {
		case R.id.iv_plus:
			Intent in = new Intent(ArtNewsActivity.this, ChannelActivity.class);
			startActivity(in);
			break;

		default:
			break;
		}
	}

//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		// String change02 = data.getStringExtra("change02");
//		// 根据上面发送过去的请求吗来区别
//		// userChannelList = ((ArrayList<ChannelItem>) manage.getUserChannel());
//		switch (requestCode) {
//		case 1:
//			// if(resultCode == 2){
//			
//
//			// }
//
//			break;
//		default:
//			break;
//		}
//	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		if (isBackFromChannel==true) {
			isBackFromChannel = false;
			// userChannelList = ((ArrayList<ChannelItem>)
			// manage.getUserChannel());
			String ids = "";
			for (int i = 0; i < userChannelList.size(); i++) {
				ids = ids + userChannelList.get(i).getId() + "+";
			}
			initNav();
			if (ChannelPosition > -1) {
				setType(ChannelPosition);
				if (!TextUtils.isEmpty(AppUtil.getUser().getToken())) {
					requestEditchannel(ids.substring(0, ids.length() - 1));
				}
			}
		}
	}


	private ChannelManage manage;

	private void initChannelList(String json) {
		int userNum = 0;
		int otherNum = 0;
		// TODO Auto-generated method stub
		// String json = MySharedPreferences.getMySharedPreferences(
		// ArtNewsActivity.this).getValue("mychannel", "");
		ChannelManage.defaultUserChannels.clear();
		ChannelManage.defaultOtherChannels.clear();
		if (!TextUtils.isEmpty(AppUtil.getUser().getToken())) {
			JSONObject channel;
			try {
				channel = new JSONObject(json);

				JSONObject mychannelObj = channel.optJSONObject("data")
						.optJSONObject("mychannel");
				JSONArray allchannelArr = channel.optJSONObject("data")
						.optJSONArray("allchannel");
				if (mychannelObj != null) {
					String[] s1 = mychannelObj.toString().split("\\+");

					for (int i = 0; i < allchannelArr.length(); i++) {
						String id = allchannelArr.optJSONObject(i).optString(
								"id");
						String title = allchannelArr.optJSONObject(i)
								.optString("title");
						boolean b = false;
						for (int j = 0; j < s1.length; j++) {
							if (s1[j].equals(id))
								b = true;
						}
						if (b) {
							userNum++;
							ChannelManage.defaultUserChannels
									.add(new ChannelItem(Integer.valueOf(id),
											title, userNum, 1));
						} else {
							otherNum++;
							ChannelManage.defaultOtherChannels
									.add(new ChannelItem(Integer.valueOf(id),
											title, otherNum, 0));
						}
					}
					manage.initDefaultChannel();
				} else {
					for (int i = 0; i < allchannelArr.length(); i++) {
						String id = allchannelArr.optJSONObject(i).optString(
								"id");
						String title = allchannelArr.optJSONObject(i)
								.optString("title");
						if (i < allchannelArr.length() / 2) {
							userNum++;
							ChannelManage.defaultUserChannels
									.add(new ChannelItem(Integer.valueOf(id),
											title, userNum, 1));
						} else {
							otherNum++;
							ChannelManage.defaultOtherChannels
									.add(new ChannelItem(Integer.valueOf(id),
											title, otherNum, 0));
						}
					}
				}
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			// JSONObject channel;
			// try {
			// channel = new JSONObject(json);
			// JSONArray allchannelArr = channel.optJSONArray("allchannel");
			//
			//
			// } catch (JSONException e) {
			// // TODO Auto-generated catch block
			// e.printStackTrace();
			// }
		}

	}

	// void setSearchAnim() {
	// textcancel = (TextView) findViewById(R.id.searchcancel);
	// textcancel.setOnClickListener(this);
	// textcancel.setVisibility(View.GONE);
	// linearSearch = (LinearLayout) findViewById(R.id.linearLayout1);
	// textSearchTag = (TextView) findViewById(R.id.textsearch);
	// viewSearch = (View) findViewById(R.id.relasearch);
	// viewSearch.setOnClickListener(this);
	// mimgMirrorCenter = (ImageView) findViewById(R.id.imageView1);
	// mimgMirrorLeft = (ImageView) findViewById(R.id.imageView2);
	// meditSearch = (EditText) findViewById(R.id.editText1);
	// meditSearch.setVisibility(View.GONE);
	// meditSearch
	// .setOnEditorActionListener(new TextView.OnEditorActionListener() {
	// public boolean onEditorAction(TextView v, int actionId,
	// KeyEvent event) {
	// if (actionId == EditorInfo.IME_ACTION_SEARCH
	// || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
	// pageIndex = 1;
	// strType = "1";
	// searchWord = meditSearch.getText().toString();
	// getArtistListData();
	// onClick(textcancel);
	// viewSearch.setVisibility(View.GONE);
	//
	// inintType();
	// return true;
	// }
	// return false;
	// }
	// });
	// mimgMirrorLeft.setVisibility(View.GONE);
	// }
	//
	// @Override
	// public void onClick(View arg0) {
	// // TODO Auto-generated method stub
	// switch (arg0.getId()) {
	// case R.id.relasearch:
	// if (!isSearching) {
	// isSearching = true;
	// Animation translateAnimation2 = new TranslateAnimation(
	// VeDate.dip2px(mContext, 160), 0f, 0f, 0f);
	// translateAnimation2.setDuration(anmiSpeed);
	// mimgMirrorLeft.setAnimation(translateAnimation2);
	// mimgMirrorLeft.setVisibility(View.VISIBLE);
	// mimgMirrorCenter.setVisibility(View.GONE);
	// textSearchTag.setVisibility(View.GONE);
	// Animation scaleAnimation = new ScaleAnimation(1f, 0.8f, 1f, 1f,
	// 1f, 1f);
	// scaleAnimation.setDuration(anmiSpeed);
	// scaleAnimation.setFillAfter(true);
	// scaleAnimation
	// .setAnimationListener(new Animation.AnimationListener() {
	// @Override
	// public void onAnimationStart(Animation arg0) {
	// // TODO Auto-generated method stub
	//
	// }
	//
	// @Override
	// public void onAnimationRepeat(Animation arg0) {
	// // TODO Auto-generated method stub
	//
	// }
	//
	// @Override
	// public void onAnimationEnd(Animation arg0) {
	// // TODO Auto-generated method stub
	// meditSearch.setVisibility(View.VISIBLE);
	// textcancel.setVisibility(View.VISIBLE);
	// meditSearch.requestFocus();
	// viewHide.setVisibility(View.VISIBLE);
	// openInput();
	//
	// }
	// });
	// linearSearch.setAnimation(scaleAnimation);
	//
	// }
	// break;
	//
	// case R.id.searchcancel:
	// if (isSearching) {
	// isSearching = false;
	// // Animation translateAnimation2 = new
	// // TranslateAnimation(0f,VeDate.dip2px(getActivity(), 160),
	// // 0f, 0f);
	// // translateAnimation2.setDuration(500);
	// // mimgMirrorLeft.setAnimation(translateAnimation2);
	// mimgMirrorCenter.setVisibility(View.GONE);
	// mimgMirrorLeft.setVisibility(View.GONE);
	// meditSearch.setText("");
	// meditSearch.setVisibility(View.GONE);
	// textSearchTag.setVisibility(View.VISIBLE);
	// Animation scaleAnimation = new ScaleAnimation(0.8f, 1f, 1f, 1f,
	// 1f, 1f);
	// scaleAnimation.setDuration(500);
	// scaleAnimation.setFillAfter(true);
	// linearSearch.setAnimation(scaleAnimation);
	// textcancel.setVisibility(View.GONE);
	// viewHide.setVisibility(View.GONE);
	// viewSearch.setVisibility(View.GONE);
	// }
	// break;
	// case R.id.view_hide_text:
	// closeInputMethod();
	// break;
	// case R.id.collecter_serach:
	// Intent intent = new Intent(mContext,CollecterSearchActivity.class);
	// startActivity(intent);
	//
	// // viewSearch.setVisibility(View.VISIBLE);
	// // onClick(viewSearch);
	// break;
	// default:
	// break;
	// }
	// }
	//
	// void openInput() {
	// InputMethodManager m = (InputMethodManager) meditSearch.getContext()
	// .getSystemService(Context.INPUT_METHOD_SERVICE);
	// m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
	// }
	//
	// void closeInputMethod() {
	// viewHide.setVisibility(View.GONE);
	// try {
	// InputMethodManager inputMethodManager = (InputMethodManager) mContext
	// .getSystemService(Context.INPUT_METHOD_SERVICE);
	// inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus()
	// .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
	// } catch (Exception e) {
	// // TODO: handle exception
	// Log.d("", "关闭输入法异常");
	// }
	// }
	public String getTime() {

		long time = System.currentTimeMillis() / 1000;// 获取系统时间的10位的时间戳

		String str = String.valueOf(time);

		return str;

	}
}
